package com.xiaoma.lock.notReentrancelock;

/**
 * https://blog.csdn.net/u012545728/article/details/80843595
 * 不可重入锁
 * @author xiaomacdut
 * @date 2020年3月24日 下午4:12:15
 */
public class Lock{
    
    private boolean isLocked = false;
    
    public synchronized void lock() throws InterruptedException{
        while(isLocked){
            wait();
        }
        isLocked = true;
    }
    
    public synchronized void unlock(){
        isLocked = false;
        notify();
    }
}
